package space.misiro.ledgers.token.exchange

import org.jboss.logging.Logger
import org.keycloak.Config
import org.keycloak.models.KeycloakSession
import org.keycloak.models.KeycloakSessionFactory
import org.keycloak.services.resource.RealmResourceProvider
import org.keycloak.services.resource.RealmResourceProviderFactory

class ConfigurableTokenResourceProviderFactory : RealmResourceProviderFactory {
    override fun create(session: KeycloakSession) = ConfigurableTokenResourceProvider(session).also {
        val configuration = ConfigurationTokenResourceConfiguration.readFromEnvironment()
        LOG.infof("Keycloak-ConfigurableToken is configured with: {}", configuration)
    }

    override fun init(p0: Config.Scope?) {
        TODO("Not yet implemented")
    }

    override fun postInit(p0: KeycloakSessionFactory?) {
        TODO("Not yet implemented")
    }

    override fun close() {
        TODO("Not yet implemented")
    }

    override fun getId() = ConfigurableTokenResourceProvider.ID

    companion object {
        val LOG: Logger = Logger.getLogger(ConfigurableTokenResourceProviderFactory::class.java)
    }
}